package com.meilele.biz.zhengchao;


import com.meilele.dao.zhengchao.FourArticleMapper;
import com.meilele.dao.zhengchao.FourContentMapper;
import com.meilele.dao.zhengchao.FourIndexImageMapper;
import com.meilele.entity.zhengchao.FourArticle;
import com.meilele.entity.zhengchao.FourIndexImage;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ImageBiz {
    @Resource
    private FourIndexImageMapper dao;
    @Resource
    private FourArticleMapper articleMapper;
    @Resource
    private FourContentMapper cdao;

    public List<FourIndexImage> findAll(){
        return dao.findAll();
    }

    public void updateById(FourIndexImage indexImage)throws Exception {
        dao.updateByPrimaryKeySelective(indexImage);
    }

    public void updateRank(String rank) throws Exception{
        String[] ssk= rank.split(",");
        FourIndexImage four=null;

        for(int i=0;i<ssk.length;i++){
            four=new FourIndexImage();
            String ss=ssk[i].substring(ssk[i].lastIndexOf("/")+1,ssk[i].length());
            four.setIndexImageId(i+1);
            four.setIndexImage(ss);
            dao.updateByPrimaryKeySelective(four);
        }
    }

    public void deleteBeach(int[] ids) {
        for(int aa:ids){
          articleMapper.deleteByPrimaryKey(aa);
          FourArticle article=articleMapper.selectByPrimaryKey(aa);
        /*  cdao.deleteByPrimaryKey(article.getFourContent().getContentId());*/
        }
    }
}
